# -*- coding: utf-8 -*-

import urllib2
import urllib
import re
from bs4 import BeautifulSoup


    # 将所有的段子都扣出来，添加到列表中并且返回列表
def GetPage(page):
    myUrl = "http://m.qiushibaike.com/hot/page/" + str(page)
    user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
    headers = { 'User-Agent' : user_agent }
    req = urllib2.Request(myUrl, headers = headers)
    myResponse = urllib2.urlopen(req)
    myPage = myResponse.read()
    soup=BeautifulSoup(myPage,'lxml')
    #获取所有div标签的内容
    QBlist=soup.find_all('div',class_='content')
    #过滤出文字段子的内容
    for i in range(len(QBlist)):
        a=str(QBlist[i])[28:-14]
        print a

GetPage(1)
